package com.xbongbong.workflow.service.operator;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.domain.entity.PaasFormDataEntity;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.workflow.domain.entity.WorkflowNodeEntity;
import com.xbongbong.paas.pojo.workflow.WorkflowDataPojo;
import com.xbongbong.workflow.pojo.WorkflowOperationsPojo;

import java.util.List;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2020/3/3 19:40
 * @since v1.0
 */
public interface WorkflowOperatorFieldHandler {

    List<Integer> type();

    /**
     * 处理本表单字段
     * @param paasFormDataEntity 主要用来取data外的数据
     * @param data 主要是用来放子表单的数据
     * @param fieldAttrEntity 字段
     * @param workflowDataPojo 容器
     * @param workflowOperationsPojo
     * @return
     * @throws XbbException
     */
    Object handlerThisFormField(PaasFormDataEntity paasFormDataEntity, JSONObject data, FieldAttrEntity fieldAttrEntity,
                                WorkflowDataPojo workflowDataPojo, WorkflowOperationsPojo workflowOperationsPojo) throws XbbException;

    /**
     * 处理目标表单
     * @param paasFormDataEntity
     * @param data
     * @param fieldAttrEntity
     * @param targetField
     * @param workflowDataPojo
     * @param workflowOperationsPojo
     * @param workflowNodeEntity
     * @return
     * @throws XbbException
     */
    Object handlerTargetFormField(PaasFormDataEntity paasFormDataEntity, JSONObject data, FieldAttrEntity fieldAttrEntity, FieldAttrEntity targetField,
                                  WorkflowDataPojo workflowDataPojo, WorkflowOperationsPojo workflowOperationsPojo, WorkflowNodeEntity workflowNodeEntity) throws XbbException;

    /**
     * 处理固定值
     * @param targetField
     * @param workflowDataPojo
     * @param workflowOperationsPojo
     * @param workflowNodeEntity
     * @return
     * @throws XbbException
     */
    Object handlerFixedValue(FieldAttrEntity targetField,
                             WorkflowDataPojo workflowDataPojo, WorkflowOperationsPojo workflowOperationsPojo, WorkflowNodeEntity workflowNodeEntity) throws XbbException;

    /**
     * 公式处理字段
     * @param fieldAttrEntity
     * @param formDataEntity
     * @param data
     * @param formId
     * @param businessType
     * @param corpid
     * @return
     * @throws XbbException
     */
    Object formulaHandlerThisField(FieldAttrEntity fieldAttrEntity, PaasFormDataEntity formDataEntity, JSONObject data,
                                   Long formId, Integer businessType, String corpid) throws XbbException ;
    /**
     * 将结果转成目标字段
     * @param value
     * @param workflowOperationsPojo
     * @param targetField
     * @param workflowNodeEntity
     * @param corpid
     * @return java.lang.Object
     * @author 吴峰
     * @date 2021/8/10 20:20
     * @throws XbbException
     */
    Object formulaHandlerTargetField(Object value, WorkflowOperationsPojo workflowOperationsPojo, FieldAttrEntity targetField,
                                     WorkflowNodeEntity workflowNodeEntity, String corpid) throws XbbException ;
}
